<template>
  <div class="timeAxis">
    <div class="timeAxis-content">
      <div class="count">时间轴：{{ timeAxis.total }}篇</div>
      <div class="timeAxis-item" v-for="item of timeAxis.timeAxisList" :key="item.monthTime">
        <div class="timeAxis-item-title"><h3>{{ item.monthTime }}</h3></div>
        <el-timeline class="timeline">
          <el-timeline-item
              v-for="(dayArticle, index) in item.dayArticleList"
              :key="index"
              :timestamp="dayArticle.dayTime"
              placement="top">
            <div class="timeline-item">
              <div class="line-item" v-for="article of dayArticle.articleList" :key="article.id">
                {{ article.createTime }}
                <router-link class="line-item-title" :to="'/article/' + article.id" tag="span">{{
                    article.title
                  }}
                </router-link>
                <i v-if="article.isStick" class="iconfont icon-top01" style="color: #f57a6c;margin-left: 20px"></i>
              </div>
            </div>
          </el-timeline-item>
        </el-timeline>
      </div>
    </div>
  </div>
</template>

<script>

import {articleTimeAxis} from "@/api/article";

export default {
  name: 'timeAxis',
  data() {
    return {
      timeAxis: []
    }
  },
  mounted() {
    this.articleTimeAxis();
  },
  methods: {
    articleTimeAxis() {
      articleTimeAxis().then(res => {
        this.timeAxis = res.data;
      })
    }
  }
}
</script>

<style scoped>
.timeAxis {
  margin: 20px 0;
  background-color: #fff;
}

.timeAxis-content {
  padding-left: 20px;
  padding-top: 20px;
}

.timeAxis-item-title {
  width: 90%;
  line-height: 40px;
  height: 40px;
  background-color: #f2f6fc;
  border-radius: 5px;
  margin: 10px 0;
  padding-left: 10px;
}

.line-item {
  line-height: 35px;
  height: 35px;
  font-size: 14px;
  font-family: "Joe Font", "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, "sans-serif";
}

.line-item:hover {
  cursor: pointer;
  color: #54a0ff;
}

.timeline {
  margin-left: 20px;
}

.timeline-item {
  width: 80%;
  margin: 10px 0;
  padding-left: 10px;
}

.el-timeline-item {
  padding-bottom: 0px;
}

.count {
  margin-bottom: 20px;
  font-size: 20px;
  color: #E6A23C;
}
</style>
